﻿@model RevalidationPageViewModel
@{
    ViewBag.Title = "Revalidation Job";
}

<section role="main" class="container main-container page-revalidation">
    <div class="row">
        <div class="col-xs-12">
            <h1>Revalidations</h1>

            @if (!Model.State.IsInitialized)
            {
                @ViewHelpers.AlertDanger(
                    @<text>
                        <strong>Uninitialized!</strong>

                        The revalidation job cannot perform revalidations as its state is uninitialized.
                    </text>)
            }

            <h2>Killswitch</h2>
            <div class="form-group danger-zone">
                <text>
                    @using (Html.BeginForm("SetKillswitch", "Revalidation", FormMethod.Post))
                    {
                        @Html.AntiForgeryToken()

                        <p>
                            Use the killswitch to disable the revalidation job if it causes ingestion pipeline issues.
                        </p>
                        <div class="form-group">
                            @if (Model.State.IsKillswitchActive)
                            {
                                @ViewHelpers.AlertWarning(
                                    @<text>
                                        <strong>Killswitch activated!</strong>

                                        Press the button below to enable revalidations.
                                    </text>)

                                <input type="hidden" name="killswitch" value="false" />
                                <input type="submit" class="btn btn-brand form-control" value="Enable Revalidations" />
                            }
                            else
                            {
                                <input type="hidden" name="killswitch" value="true" />
                                <input type="submit" class="btn btn-brand-danger form-control" value="Activate the Killswitch" />
                            }
                        </div>
                    }
                </text>
            </div>

            <h2>Statistics</h2>

            <p>
                <strong>Revalidations Left:</strong>
                @Model.Statistics.PendingRevalidations.ToString("n0")
            </p>
            <p>
                <strong>Revalidations Started In Last Hour:</strong>
                @Model.Statistics.StartedRevalidationsInLastHour.ToString("n0")
            </p>
            <p>
                <strong>Total Revalidations Started:</strong>
                @Model.Statistics.StartedRevalidations.ToString("n0")
            </p>
            <p>
                <strong>Desired Package Event Rate*:</strong>
                @Model.State.DesiredPackageEventRate events per hour
            </p>

            <p>* The package ingestion rate which should be achievable without health degradation, as determined by the revalidation job.</p>
        </div>
    </div>
</section>